<?php

namespace app\exception;

use support\BaseResponse;
use Webman\Http\Request;
use Webman\Http\Response;

class NormalExceptionHandle
{
    public function report($e){

    }

    public function render(Request $request,\Throwable $e): ?Response
    {
        if ($e instanceof \Exception) {
            (new \app\utils\alarms\AlarmsSupport())->push($e);
        }
        //校验失败
        if ($e instanceof ValidateException) {
            //不进行飞书的推送了
        }
        //业务失败
        if ($e instanceof ExpressException) {
            //不进行飞书的推送了
        }
        return BaseResponse::fail($e->getMessage(),$e->getCode() ?: 500);
    }
}